package com.test30_IO流;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;

/**
 * BufferedReader，缓冲输入流
 */
public class Demo14_BufferedReader {

    public static void main(String[] args) throws Exception {
//        test1();
        test2();
    }

    /**
     * 读取键盘输入内容
     */
    public static void test1() throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("请输入你要发送的信息：");
        String str = input.readLine();
        System.out.println("【数据回显】" + str);
        input.close();
    }

    /**
     * 读取文本数据信息
     */
    public static void test2() throws Exception {
        File file = new File("F:" + File.separator + "muyan" + File.separator + "message.txt");
        BufferedReader input = new BufferedReader(new FileReader(file));
        String data = null;
        while ((data = input.readLine()) != null) {
            System.out.println(data);
        }
        input.close();
    }
}
